import { createRouter, createWebHistory } from 'vue-router';

// 懒加载视图组件
const Home = () => import('../views/Home.vue');
const Assessment = () => import('../views/Assessment.vue');
const Report = () => import('../views/Report.vue');
const About = () => import('../views/About.vue');

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home,
    meta: {
      title: '大学生就业成熟度评估系统'
    }
  },
  {
    path: '/assessment/:conversationId?',
    name: 'Assessment',
    component: Assessment,
    meta: {
      title: '就业成熟度评估'
    }
  },
  {
    path: '/report/:conversationId',
    name: 'Report',
    component: Report,
    meta: {
      title: '评估报告'
    }
  },
  {
    path: '/about',
    name: 'About',
    component: About,
    meta: {
      title: '关于系统'
    }
  },
  // 404页面
  {
    path: '/:pathMatch(.*)*',
    redirect: '/'
  }
];

const router = createRouter({
  history: createWebHistory(),
  routes
});

// 路由前置守卫，设置页面标题
router.beforeEach((to, from, next) => {
  document.title = to.meta.title || '大学生就业成熟度评估系统';
  next();
});

export default router;